#!/bin/sh

pid=/run/vpnc/pid

if [ $# -ne 0 ]; then
	echo "Usage: $0" 1>&2
	exit 1
fi

PID="$(cat "$pid" 2> /dev/null)"

if [ -z "$PID" ]; then
	echo "no vpnc found running"
	exit 1
fi

if ! kill -0 "$PID" > /dev/null 2>&1; then
	echo "no vpnc found running"
	exit 1
fi

echo "Terminating vpnc daemon (pid: $PID)"
exec kill $PID
